package com.example.springboot.config.event.generic;

import com.example.springboot.bean.Department;
import com.example.springboot.pojo.Person;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author chenzhangkun
 * @ClassName PublishBaseEventService
 * @description: TODO
 * @date 2024年01月18日
 */
@Service
public class PublishBaseEventService {
    @Resource
    private ApplicationContext applicationContext;

    public void publish() {
        // 发布person事件
        applicationContext.publishEvent(new BaseEvent<>(new Person(), "add"));
        // 发送department事件
        applicationContext.publishEvent(new BaseEvent<>(new Department(), "update"));
    }
}
